[PATCH] util: fix max socket calculation#10
Closed
3d0c wants to merge 1 commit intoNVIDIA:nvidia_stable-11.8from
Closed
[PATCH] util: fix max socket calculation#103d0c wants to merge 1 commit intoNVIDIA:nvidia_stable-11.8from
3d0c wants to merge 1 commit intoNVIDIA:nvidia_stable-11.8from
Conversation
This patch changes how the maximum socket count is calculated.
On some systems (e.g. GB200), physical_package_id values are not
contiguous or zero-based. Instead of 0..N, they may contain large
arbitrary identifiers (e.g. 256123234). The previous implementation
assumed a 0..N range and used the maximum ID value directly.
This caused:
excessive memory allocation
extremely large loop bounds
OOM / DoS scenarios
unnecessary CPU time consumption
The new implementation computes the socket count as the number of unique
package IDs present on the node, rather than relying on the maximum numeric
value.
824c4b0 to
df3a519
Compare
Collaborator
|
Closing as we are picking upstream commit for this fix in the following PR: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem Description
Libvirt determines the number of CPU sockets by reading values from topology/physical_package_id. The existing logic implicitly assumes that these values are small, zero-based, and contiguous integers (0, 1, …, N). This assumption holds true on most systems.
However, on some platforms (for example, NVIDIA GB200), physical_package_id contains large, non-contiguous numeric identifiers such as 268435234 or 285212456. These values are identifiers, not indices.
Original implementation incorrectly treated the maximum numeric value of physical_package_id as the socket count. This value was then used as an upper bound in multiple code paths, including memory allocation and iteration logic. For example:
for (i = 0; i < sock_max; i++)
cores_maps[i] = virBitmapNew(0);
On affected systems, this resulted in loop bounds in the hundreds of millions, leading to:
excessive memory allocation
extremely large iteration counts
high CPU consumption
OOM
On Kubevirt this is triggered immediately by GetDomainStats and causes
virtqemudto run out of memory:The fix has been validated on: